package com.enjoyor.soa.traffic.rest.efoms.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.enjoyor.soa.traffic.api.dto.efoms.CheckDeviceInfoDto;
import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IAssetInfoConsumeService;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;

@Auth
@RestController
@RequestMapping({ "/AssetInfo" })
@Api("AssetInfoController")
@CrossOrigin
public class AssetInfoController {

	@Autowired
	private IAssetInfoConsumeService assetInfoConsumeService; 
	/**
	 * 根据输入的查询时间范围查询故障次数的饼形图
	 * @param beginTime 开始时间
	 * @param endTime 结束时间
	 * @param assentId 资产编号
	 * @param typeCode 类型编号
	 * @return
	 */
	@GetMapping(value = { "/getDevFaultPie" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
    @ApiOperation("查询故障次数的饼形图")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "assentId", value = "资产编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "typeCode", value = "类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getDevFaultPie(
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			@RequestParam(defaultValue = "",value="assentId",required=false) String assentId,
			@RequestParam(defaultValue = "",value="typeCode",required=false) String typeCode,
			HttpServletRequest request) {
		return assetInfoConsumeService.getDevFaultPie(beginTime, endTime, assentId, typeCode);
	}
	
	/**
	 * 根据输入的查询时间范围查询故障次数折线图
	 * @param beginTime 开始时间
	 * @param endTime 结束时间
	 * @param assentId 资产编号
	 * @param typeCode 类型编号
	 * @return
	 */
	@GetMapping(value = { "/getDevFaultLine" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
    @ApiOperation("查询故障次数折线图")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "assentId", value = "资产编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "typeCode", value = "类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getDevFaultLine(
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			@RequestParam(defaultValue = "",value="assentId",required=false) String assentId,
			@RequestParam(defaultValue = "",value="typeCode",required=false) String typeCode,
			HttpServletRequest request) {
		return assetInfoConsumeService.getDevFaultLine(beginTime, endTime, assentId, typeCode);
	}
	
	/**
	 * 根据输入的查询时间范围查询故障次数折线图
	 * @param beginTime 开始时间
	 * @param endTime 结束时间
	 * @param assentId 资产编号
	 * @param typeCode 类型编号
	 * @return
	 */
	@GetMapping(value = { "/getDevCheckTimesLine" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
    @ApiOperation("查询故障次数折线图")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "assentId", value = "资产编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "typeCode", value = "类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "checkResultCode", value = "巡检结果编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "searchFlag", value = "时间维度(年YEAR,月MONTH 必填)", paramType = "query", dataType = "String")})
	public ResultPojo getDevCheckTimesLine(
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			@RequestParam(defaultValue = "",value="assentId",required=false) String assentId,
			@RequestParam(defaultValue = "",value="typeCode",required=false) String typeCode,
			@RequestParam(defaultValue = "",value="checkResultCode",required=false) String checkResultCode,
			@RequestParam(defaultValue = "",value="searchFlag",required=false) String searchFlag,
			HttpServletRequest request) {
		return assetInfoConsumeService.getDevCheckTimesLine(beginTime, endTime, assentId, typeCode,checkResultCode,searchFlag);
	}
	
	/**
	 * 根据输入的查询时间范围查询报警类型的饼形图
	 * @param beginTime 开始时间
	 * @param endTime 结束时间
	 * @param assentId 资产编号
	 * @param typeCode 类型编号
	 * @return
	 */
	@GetMapping(value = { "/getDevWarnTypePie" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
    @ApiOperation("查询报警类型的饼形图")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "assentId", value = "资产编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "typeCode", value = "类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "warnLevelCode", value = "报警等级编号", paramType = "query", dataType = "String")})
	public ResultPojo getDevWarnTypePie(
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			@RequestParam(defaultValue = "",value="assentId",required=false) String assentId,
			@RequestParam(defaultValue = "",value="typeCode",required=false) String typeCode,
			@RequestParam(defaultValue = "",value="warnLevelCode",required=false) String warnLevelCode,
			HttpServletRequest request) {
		return assetInfoConsumeService.getDevWarnTypePie(beginTime, endTime, assentId, typeCode,warnLevelCode);
	}
	
	/**
	 * 根据输入的查询时间范围查询报警类型的饼形图
	 * @param beginTime 开始时间
	 * @param endTime 结束时间
	 * @param assentId 资产编号
	 * @param typeCode 类型编号
	 * @return
	 */
	@GetMapping(value = { "/getDevWranTimesLine" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
    @ApiOperation("查询报警类型的折线图")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "assentId", value = "资产编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "typeCode", value = "类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "warnLevelCode", value = "报警等级编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "searchFlag", value = "时间维度(年YEAR,月MONTH 必填)", paramType = "query", dataType = "String")})
	public ResultPojo getDevWranTimesLine(
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			@RequestParam(defaultValue = "",value="assentId",required=false) String assentId,
			@RequestParam(defaultValue = "",value="typeCode",required=false) String typeCode,
			@RequestParam(defaultValue = "",value="warnLevelCode",required=false) String warnLevelCode,
			@RequestParam(defaultValue = "",value="searchFlag",required=false) String searchFlag,
			HttpServletRequest request) {
		return assetInfoConsumeService.getDevWranTimesLine(beginTime, endTime, assentId, typeCode, warnLevelCode, searchFlag);
	}
	
	/**
	 * 资产查询；
	 * @param assentId 资产编号
	 * @param typeCode 类型编号
	 * @return
	 */
	@GetMapping(value = { "/getPortRait" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
    @ApiOperation("资产画像查询；")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "assentId", value = "资产编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "typeCode", value = "类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getPortRait(
			@RequestParam(defaultValue = "",value="assentId",required=false) String assentId,
			@RequestParam(defaultValue = "",value="typeCode",required=false) String typeCode,
			HttpServletRequest request) {
		return assetInfoConsumeService.getPortRait(assentId, typeCode);
	}
}
